package com.leetcode.partition14;

import com.leetcode.common.TreeNode;

/**
 * @author rkc
 * @date 2022/9/8 10:20
 */
public class LC1379找出克隆二叉树中的相同节点 {

    public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {
        if (original == null) return null;
        if (cloned.val == target.val) return cloned;
        TreeNode l = getTargetCopy(original.left, cloned.left, target), r = getTargetCopy(original.right, cloned.right, target);
        return l == null ? r : l;
    }
}
